package day07;

import java.util.Scanner;

public class HomeworkCalTotalAvg {

    public static double avg(double[] score){
        double sum=total(score);
        double avg=sum/(score.length-2);
        return avg;
    }



    public static double total(double[] score){  //计算总分

        double total=0.0;
        double max=score[0];
        double min=score[0];
        for(int i=1;i<score.length;i++){
            if(score[i]>max){
                max=score[i];
            }
            else if(score[i]<min){
                min=score[i];
            }

        }
        for(int i=0;i<score.length;i++){
            total+=score[i];
        }
        return (total-max-min);



    }


    public static double[] getscore(){     //得出评委分数
        double[] score=new double[6];
        Scanner scanner=new Scanner(System.in);
        for(int i=0;i<score.length;i++)
        {
            System.out.println("请输入第"+(i+1)+"个评委的分数");
            score[i]=scanner.nextDouble();
        }
        return score;
    }
    public static void main(String[] args) {
        double[] score=getscore();
        double total=total(score);
        double avg=avg(score);
        System.out.println("最后成绩为："+total);
        System.out.println("平均分为："+avg);

    }
}
